import * as types from './mutation-type'

export const increment2 = function ({ commit }) {
  setTimeout(() => {
    commit(types.INCREMENT, 2)
  }, 300)
}

export const addItem = function ({ commit, state }, shop) {
  const product = state.items.find((e) => e.id == shop.id)
  if (product) {
    commit(types.ADD_ITEM_NUM, shop)
  } else {
    commit(types.ADD_TO_ITEMS, shop)
  }
}
